<?php

namespace Boer\Controller;

use Common\Controller\AdminbaseController;

class ConsultController extends AdminbaseController {

    protected $m_Consult;
    //想合作的类型
    protected  $cooperate_type = array(
        '1'=>array(
            '1'=>'供应商',
            '2'=>'分销商',
            '3'=>'区域合作伙伴',
            '4'=>'技术合作伙伴',
            '5'=>'投资',
            '6'=>'企业主'
        ),
        '2'=>array(
            '1'=>'supplier',
            '2'=>'Distributor',
            '3'=>'Regional partners',
            '4'=>'Technical partner',
            '5'=>'Investment',
            '6'=>'Business owners'
        )
    );
    //公司类型
    protected  $company_type = array(
        '1'=>array(
            '1'=>'国有企业',
            '2'=>'民营企业',
            '3'=>'上市公司',
            '4'=>'外资企业',
            '5'=>'其他',
        ),
        '2'=>array(
            '1'=>'State - owned enterprises',
            '2'=>'Private Enterprise',
            '3'=>'Listed company',
            '4'=>'Foreign companies',
            '5'=>'others',
        )
    );
    function _initialize() {
        parent::_initialize();
        $this->m_Consult= D("Boer/Boer_consult");
    }

    /**
     * 列表页
     */
    public function index(){
        $keyword = I("post.keyword");
        $this->assign("keyword",$keyword);
        $where = array();
        if(!empty($keyword)){
            $where['question'] = array('like',"%$keyword%");
        }

        $count=$this->m_Consult->where($where)->count();
        $page = $this->page($count, 15);
        $list = $this->m_Consult->where($where)
            ->order("create_time desc")
            ->limit($page->firstRow , $page->listRows)
            ->select();
        foreach($list AS &$litem){
            $litem['cooperate_type'] = $this->cooperate_type[$litem['language']][$litem['cooperate_type']];
            $litem['company_type'] = $this->company_type[$litem['language']][$litem['company_type']];
        }
        $this->assign("page", $page->show('Admin'));
        $this->assign("list",$list);
        $this->display();
    }

}